<script type="text/javascript">
    $(function() {
        $("#valor").maskMoney({decimal: ",", thousands: "."});
        $('#vencimento').mask('99/99/9999');
    });
</script>
<center>
    <?php echo $this->view->menssagem; ?>
    <div class="panel panel-default" style="width: 600px">

        <div class="panel-heading" style="font-weight:  bolder">Cadastro de Conta</div>

        <div class="panel-body">

            <form class="form-horizontal" role="form" method="post" action="/caixa/conta_add">

                <?php
                if (isset($this->view->conta['id'])) {
                    echo "<input class='form-control'  type='hidden' name='id' value='{$this->view->conta['id']}' />'";
                }
                ?>
                <div class="form-group">
                    <label for="numero_documento" class="col-sm-4 control-label">Numero Documento</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="numero_documento" id="numero_documento"
                        <?php
                        if (isset($this->view->conta)) {
                            echo " value='{$this->view->conta['numero_documento']}' ";
                        }
                        ?>
                               />
                    </div>
                </div>
                <div class="form-group">
                    <label for="beneficiario" class="col-sm-4 control-label">Beneficiario</label>
                    <div class="col-sm-5">
                        <select class="form-control" type="text" itemid="3" name="beneficiario" id="beneficiario" >
                            <option value="0" >Selecione</option>
                            <?php
                            foreach ($this->view->lista as $c) {

                                if (isset($this->view->conta)) {
                                    if ($c['id'] == $this->view->conta['beneficiario']) {
                                        echo '<option style="fonte-weight:bold;" selected="true"  value="' . $c['id'] . '">' . $c['nome'] . '</option>';
                                    } else {
                                        echo '<option style="fonte-weight:bold;" value="' . $c['id'] . '">' . $c['nome'] . '</option>';
                                    }
                                } else {
                                    echo '<option style="fonte-weight:bold;" value="' . $c['id'] . '">' . $c['nome'] . '</option>';
                                }
                            }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="valor" class="col-sm-4 control-label" >Valor</label>
                    <div class="col-sm-5">
                        <input class="form-control" type="text"
                        <?php
                        if (isset($this->view->conta['valor'])) {
                            echo " value='{$this->view->conta['valor']}' ";
                        } else {
                            echo 'value="0,00"';
                        }
                        ?>
                               name="valor" id="valor"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="vencimento" class="col-sm-4 control-label">Vencimento</label>
                    <div class="col-sm-5">
                        <input class="form-control" type="text" name="vencimento" id="vencimento"
                        <?php
                        if (isset($this->view->conta['vencimento'])) {
                            echo "value='" . \SON\UTIL\Converter::dataParaString($this->view->conta['vencimento']) . "\'";
                        }
                        ?>
                               />
                    </div>
                </div>
                <div class="form-group">
                    <label for="descricao" class="col-sm-4 control-label">Descrição</label>
                    <div class="col-sm-8">
                        <textarea class="form-control" type="text" name="descricao" id="descricao"><?php
                            if (isset($this->view->conta)) {
                                echo $this->view->conta['descricao'];
                            }
                            ?></textarea>

                    </div>
                </div>
                <div class="form-group">
                    <div align="right" class="col-sm-offset-2 col-sm-10">
                        <button class="btn btn-primary" type="submit" ><span class="glyphicon glyphicon-floppy-disk"></span> Salvar</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</center>
